package cn.com.chengmandian.bike.controller;


import cn.com.chengmandian.bike.model.EbCardInfo;
import cn.com.chengmandian.bike.model.vo.CardInfoVo;
import cn.com.chengmandian.bike.service.IEbCardInfoService;
import cn.com.chengmandian.core.web.pojo.AgentInfo;
import cn.com.chengmandian.core.web.pojo.AjaxResult;
import cn.com.chengmandian.core.web.utils.LocalMapUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 骑行卡信息列表 前端控制器
 * </p>
 *
 * @author AutoGenerator
 * @since 2021-12-11
 */
@Api(tags = "骑行卡相关接口")
@RestController
@RequestMapping("/card/info")
public class EbCardInfoController {
    @Autowired
    private IEbCardInfoService cardInfoService;

    @ApiOperation("在售骑行卡列表(无需登录)")
    @GetMapping("/list")
    public AjaxResult<List<EbCardInfo>> list() {
        AgentInfo agentInfo = LocalMapUtil.getAgentInfo();
        Assert.notNull(agentInfo.getAreaId(), "缺少运营区ID");
        return AjaxResult.success(cardInfoService.getInfoList(agentInfo.getAreaId()));
    }

    @ApiOperation("详情(无需登录)")
    @GetMapping("/detail")
    public AjaxResult<CardInfoVo> detail(Integer id) {
        return AjaxResult.success(cardInfoService.detail(id));
    }
}
